﻿(function(angular) {
    'use strict';

    angular.module('Services', [])
        .service('StoreRepository', [
            '$http', function($http) {

                var apiUrl;

                function setApiUrl(url) {
                    apiUrl = url;
                }

                function getStoreTitle(id) {
                    var url = apiUrl + '/' + id + '/title';

                    return $http.get(url);
                }

                function getProductList(id) {

                    var url = apiUrl + '/' + id + '/products';

                    return $http.get(url);
                }

                return {
                    getProductList: getProductList,
                    getStoreTitle: getStoreTitle,
                    setApiUrl: setApiUrl
                }
            }
        ]);
})(window.angular);